package com.github.lzm320a99981e.autocoding.domain.mybatis;

import com.github.lzm320a99981e.autocoding.domain.Treeable;
import com.github.lzm320a99981e.zodiac.component.tools.TreeTransfer;

import java.util.Collection;
import java.util.List;

/**
 * tree 结构辅助类
 */
public class TreeableHelper {
    private TreeableHelper() {
    }

    /**
     * 层级化
     *
     * @param nodes
     * @return
     */
    public static <T extends Treeable> List<T> hierarchical(Collection<T> nodes) {
        return TreeTransfer.create("id", "extNodeParentId", "children").transform(nodes);
    }
}
